<?php
/**
 * Created by PhpStorm.
 * User: changyifan
 * Date: 2018/4/28
 * Time: 下午3:00
 */

namespace Home\Model;
use Think\Model\BaseModel;

class ExerciseModel extends BaseModel{

    protected $_link = array(
        'Point'=>array(
            'mapping_type' => self::BELONGS_TO,
            'class_name' => 'Point',
            'foreign_key' => 'poi_id',
            'mapping_fields' => 'poi_content',
            'as_fields' => 'knowledge_content'
        ),
        'Teacher' => array(
            'mapping_type' => self::BELONGS_TO,
            'class_name' => 'Teacher',
            'foreign_key' => 'tea_id',
            'mapping_fields' => 'tea_name',
            'as_fields' => 'tea_name'
        )
    );
    public function getExerciseInfoList($poi_id,$exe_type,$exe_diff){
        if ($poi_id == 0){
            $poi_info = $this->event->getPointInfoList();
            $con = array();
            foreach($poi_info as $key => $value){
                $con[$key] = $value['knowledge_id'];
            }
            $poi_id = array('in',$con);
        }
        if ($exe_type === '0'){
            $exe_type = array('like','%%');
        }
        if ($exe_diff == 0){
            $exe_diff = array('like','%%');
        }
        $arr['poi_id'] = $poi_id;
        $arr['exe_type'] = $exe_type;
        $arr['exe_difficulty'] = $exe_diff;
        $info = $this->where($arr)->relation(true)->select();
        return $info ? $info : array();
    }


}